/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.web.dto.response.monitor;

import com.monkey.core.web.response.MonkeyResponseDto;
import org.hibernate.metadata.ClassMetadata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author Wu Tianqiang
 */
public class JPAConfigResponseJSONDto extends MonkeyResponseDto {
    private List<ClassMetadataJSONDto> classMetadatas;

    private Map<String, String> properties = new HashMap<>();

    public JPAConfigResponseJSONDto(Map<String, ClassMetadata> allClassMetadata, Map<String, Object> props) {
        this.classMetadatas = ClassMetadataJSONDto.toJSONDto(allClassMetadata);
        Set<String> keys = props.keySet();
        for (String key : keys) {
            if (key.startsWith("hibernate") || key.startsWith("net") || key.startsWith("javax")) {
                properties.put(key, props.get(key).toString());
            }
        }
    }

    public List<ClassMetadataJSONDto> getClassMetadatas() {
        return classMetadatas;
    }

    public void setClassMetadatas(List<ClassMetadataJSONDto> classMetadatas) {
        this.classMetadatas = classMetadatas;
    }

    public Map<String, String> getProperties() {
        return properties;
    }

    public void setProperties(Map<String, String> properties) {
        this.properties = properties;
    }
}